package com.ruoyi.lxzx.mapper;

import java.util.List;

import com.ruoyi.lxzx.appVO.lxjhVO.hdjhVO;
import com.ruoyi.lxzx.appVO.lxjhVO.myHdjhVO;
import com.ruoyi.lxzx.domain.UserActivity;
import com.ruoyi.lxzx.domain.UserAttent;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 活动Mapper接口
 * 
 * @author ruoyi
 * @date 2024-10-26
 */
public interface UserActivityMapper 
{
    /**
     * 查询活动
     * 
     * @param id 活动主键
     * @return 活动
     */
    public UserActivity selectUserActivityById(Long id);

    /**
     * 查询活动列表
     * 
     * @param userActivity 活动
     * @return 活动集合
     */
    public List<UserActivity> selectUserActivityList(UserActivity userActivity);

    /**
     * 新增活动
     * 
     * @param userActivity 活动
     * @return 结果
     */
    public int insertUserActivity(UserActivity userActivity);

    /**
     * 修改活动
     * 
     * @param userActivity 活动
     * @return 结果
     */
    public int updateUserActivity(UserActivity userActivity);

    /**
     * 删除活动
     * 
     * @param id 活动主键
     * @return 结果
     */
    public int deleteUserActivityById(Long id);
 /**
     * 活动人数已满
     *
     * @param id 活动主键
     * @return 结果
     */
    public int fillUserActivityById(Long id);

    /**
     * 批量删除活动
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteUserActivityByIds(Long[] ids);

    List<hdjhVO> hdjh();

    UserActivity hdjhxq(@Param("id") Long id);

    List<UserActivity> wdjh(@Param("userId") Long userId);

    @Select("SELECT\n" +
            "\tua.id,ua.type,ua.cover,ua.theme,ua.start_time as startTime,ua.end_time as endTime,ua.address,ua.apply_cond as applyCond,ua.content,ua.content_img as contentImg,ua.content_video as contentVideo,\n" +
            "\tsu2.user_id as userId,\n" +
            "\tsu2.nick_name as name,\n" +
            "\tuc.img as img,uc.tel as tel\n" +
            "FROM\n" +
            "\tuser_activity ua\n" +
            "\tLEFT JOIN activity_apply aa ON ua.id = aa.activity_id\n" +
            "\tLEFT JOIN sys_user su1 ON aa.user_id = su1.user_id \n" +
            "\tLEFT JOIN sys_user su2 ON ua.create_by = su2.user_id \n" +
            "\tLEFT JOIN user_card uc on su2.user_id = uc.user_id\n" +
            "WHERE\n" +
            "\tsu1.user_id = #{userId}\n" +
            "        order by ua.create_time desc")
    List<myHdjhVO> wcjd(@Param("userId") Long userId);

    @Select("SELECT\n" +
            "\tua.id,ua.type,ua.cover,ua.theme,ua.start_time as startTime,ua.end_time as endTime,ua.address,ua.apply_cond as applyCond,ua.content,ua.content_img as contentImg,ua.content_video as contentVideo,\n" +
            "\tsu.user_id as userId,\n" +
            "\tsu.nick_name as name,\n" +
            "\tuc.img as img,uc.tel as tel\n" +
            "FROM\n" +
            "\tuser_activity ua\n" +
            "\tLEFT JOIN sys_user su ON ua.create_by = su.user_id \n" +
            "\tLEFT JOIN user_card uc on su.user_id = uc.user_id\n" +
            "WHERE\n" +
            "\tsu.user_id = #{userId}\n" +
            "order by ua.create_time desc")
    List<myHdjhVO> wfbd(@Param("userId") Long userId);
}
